//
// Copyright (C) [2024] Xingyun Integrated Circuit, Inc.
//
// GreenCode was a private technology asset of Xingyun Integrated Circuit， Inc （Confidential）
//  Author: Shawn.Tan
//  Date : 2025.10.28
//
//  History : Initial Version 2025.10.28
//
//
#ifndef Green_OperandSolution_H
#define Green_OperandSolution_H

#include <map>

#include "Defines.h"
#include "UopInterface.h"

namespace Green {

  class Operand;
  class ConstraintSet;
  class Register;

  /*!
    \class OperandSolution
    \brief Wrapper around operands that provides a convenient interface for solving for operand values.
  */
  class OperandSolution {
  public:
    explicit OperandSolution(Operand* pOperand); //!< Constructor
    OperandSolution(const OperandSolution& rOther); //!< Copy constructor
    OperandSolution(OperandSolution&& rOther); //!< Move constructor
    OperandSolution& operator=(const OperandSolution& rOther); //!< Assignment operator
    ~OperandSolution(); //!< Destructor

    const Register* GetRegister() const; //!< Return register intended to be assigned to operand if one exists; will return null otherwise.
    Operand* GetOperand() const; //!< Return operand represented by this OperandSolution.
    const ConstraintSet* GetConstraint() const; //!< Return set of values that may be assumed by the operand.
    uint64 GetValue() const; //!< Return value intended to be assigned to operand.
    EUopParameterType GetUopParameterType() const; //!< Return type to be used in the Uop interface.
    std::string GetName() const; //!< Return operand name.
    void SetRegister(Register* pReg); //!< Set register intended to be assigned to operand.
    void SetValue(cuint64 value); //!< Set value intended to be assigned to operand.
  private:
    void InitializeConstraintFromRegister(const Register& rReg); //!< Get the set of values that may be assumed by the specified register.
  private:
    const Register* mpReg; //!< Register intended to be assigned to operand;
    Operand* mpOperand; //!< Operand represented by this OperandSolution.
    ConstraintSet* mpConstr; //!< Set of values that may be assumed by the operand.
    uint64 mValue; //!< Value intended to be assigned to operand.
    EUopParameterType mUopParamType; //!< Type to be used in the Uop interface.
  };
}

#endif  // Green_OperandSolution_H
